//https://leetcode.cn/problems/single-number-iii/description/

class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {

        //1.排序
        sort(nums.begin(), nums.end());
        //双指针
        int left = 0, right = nums.size() - 1;
        while (left < right - 1)
        {
            if (nums[left] == nums[left + 1])
            {
                left += 2;
            }

            if (nums[right] == nums[right - 1])
            {
                right -= 2;
            }

            if (nums[left] != nums[left + 1] && nums[right] != nums[right - 1])
                break;
        }

        return { nums[left],nums[right] };

    }
};